package nimble.wechat;

import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WeChatTest {

    private static final Logger logger=LoggerFactory.getLogger(WeChatTest.class);

    public static void main(String[] args) throws Exception
    {
        WxMpService wxMpService=new WxMpServiceImpl();
        WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage();
        configStorage.setAppId("wxc85e2d0d80b10eba");
        configStorage.setSecret("6593694e09a8acf9e7369ea13ffaacc8");
        wxMpService.setWxMpConfigStorage(configStorage);
        String code="001GHPAl03JWOl1A5Hzl0JvSAl0GHPA4";
        WxMpOAuth2AccessToken wxMpOAuth2AccessToken=wxMpService.oauth2getAccessToken(code);
        WxMpUser wxMpUser=wxMpService.oauth2getUserInfo(wxMpOAuth2AccessToken,"zh_CN");
        logger.info("{},{},{}",wxMpUser.getCountry(),wxMpUser.getProvince(),wxMpUser.getCity());
        String accessToken=wxMpService.getAccessToken();
    }
}
